﻿using DWH.PP.LoopUrls.tumblr;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using System;
using System.Collections.Generic;
using DWH.Utils;

namespace RDTest
{
    
    
    /// <summary>
    ///This is a test class for TumblrPicturePullTaskTest and is intended
    ///to contain all TumblrPicturePullTaskTest Unit Tests
    ///</summary>
    [TestClass()]
    public class TumblrPicturePullTaskTest
    {


        private TestContext testContextInstance;

        /// <summary>
        ///Gets or sets the test context which provides
        ///information about and functionality for the current test run.
        ///</summary>
        public TestContext TestContext
        {
            get
            {
                return testContextInstance;
            }
            set
            {
                testContextInstance = value;
            }
        }

        #region Additional test attributes
        // 
        //You can use the following additional attributes as you write your tests:
        //
        //Use ClassInitialize to run code before running the first test in the class
        //[ClassInitialize()]
        //public static void MyClassInitialize(TestContext testContext)
        //{
        //}
        //
        //Use ClassCleanup to run code after all tests in a class have run
        //[ClassCleanup()]
        //public static void MyClassCleanup()
        //{
        //}
        //
        //Use TestInitialize to run code before running each test
        //[TestInitialize()]
        //public void MyTestInitialize()
        //{
        //}
        //
        //Use TestCleanup to run code after each test has run
        //[TestCleanup()]
        //public void MyTestCleanup()
        //{
        //}
        //
        #endregion


        /// <summary>
        ///A test for ProcessTargetHtmlContent
        ///</summary>
        [TestMethod()]
        [DeploymentItem("DWH.dll")]
        public void DownloadPicTest()
        {
            TumblrPicturePullTask target = new TumblrPicturePullTask(); 
            target.Enable = true;
            Guid newId = Guid.NewGuid();
            target.TaskName = "UT for TumblrPicturePullTask" + newId.ToString();

            target.ExtendData = new Dictionary<string, string>();
            target.ExtendData[DWHConstants.KEY_CONTENT_PAGE_URL_PATTERN] = @"http://\d+.media.tumblr.com/tumblr";//http://24.media.tumblr.com/tumblr_m158zdQV1w1rqr5kgo1_500.jpg

            target.ExtendData[DWHConstants.KEY_LOOP_PAGELIST_URL_PATTERN] = "http://realsexrealpeople.tumblr.com/page/{0}";//http://realsexrealpeople.tumblr.com/page/2
            target.ExtendData[DWHConstants.KEY_LOOP_PAGELIST_NUMBER_START] = "1";
            target.ExtendData[DWHConstants.KEY_LOOP_PAGELIST_NUMBER_END] = "10";
            target.ExtendData[DWHConstants.KEY_WEB_ATTACHMENT_STORE_FOLDER] = "E:/WebPPAttachment/Tumblr";
            target.ExtendData[DWHConstants.KEY_PAGE_TARGET_ELEMENT] = "//img";
            target.ExtendData[DWHConstants.KEY_PAGE_TARGET_ATTRIBUTE] = "src";

            target.ExtendData[DWHConstants.KEY_PAGE_ENCODING] = "gb2312";//gb2312
            target.ExtendData[DWHConstants.KEY_CONTENT_TARGET_ELEMENT] = "//div[@class]";
            target.ExtendData[DWHConstants.KEY_CONTENT_TARGET_ELEMENT_ATTRIBUTE_NAME] = "class";
            target.ExtendData[DWHConstants.KEY_CONTENT_TARGET_ELEMENT_ATTRIBUTE_VALUE] = @"postContent";

            target.Initialize();
            target.Run(); 
        }

        [TestMethod()]        
        public void mysexaddictionTest()
        {
            TumblrPicturePullTask target = new TumblrPicturePullTask();
            target.Enable = true;
            Guid newId = Guid.NewGuid();
            target.TaskName = "UT for TumblrPicturePullTask" + newId.ToString();

            target.ExtendData = new Dictionary<string, string>();
            target.ExtendData[DWHConstants.KEY_CONTENT_PAGE_URL_PATTERN] = @"http://\d+.media.tumblr.com/tumblr";//http://24.media.tumblr.com/tumblr_m158zdQV1w1rqr5kgo1_500.jpg

            target.ExtendData[DWHConstants.KEY_LOOP_PAGELIST_URL_PATTERN] = "http://my-sex-addiction.tumblr.com/page/{0}";//http://realsexrealpeople.tumblr.com/page/2
            target.ExtendData[DWHConstants.KEY_LOOP_PAGELIST_NUMBER_START] = "1";
            target.ExtendData[DWHConstants.KEY_LOOP_PAGELIST_NUMBER_END] = "10";
            target.ExtendData[DWHConstants.KEY_WEB_ATTACHMENT_STORE_FOLDER] = "E:/WebPPAttachment/Tumblr";
            target.ExtendData[DWHConstants.KEY_PAGE_TARGET_ELEMENT] = "//img";
            target.ExtendData[DWHConstants.KEY_PAGE_TARGET_ATTRIBUTE] = "src";

            target.ExtendData[DWHConstants.KEY_PAGE_ENCODING] = "gb2312";//gb2312
            target.ExtendData[DWHConstants.KEY_CONTENT_TARGET_ELEMENT] = "//div[@class]";
            target.ExtendData[DWHConstants.KEY_CONTENT_TARGET_ELEMENT_ATTRIBUTE_NAME] = "class";
            target.ExtendData[DWHConstants.KEY_CONTENT_TARGET_ELEMENT_ATTRIBUTE_VALUE] = @"postContent";

            target.Initialize();
            target.Run();
        }

        [TestMethod()]
        public void sexislovelyTest()
        {
            TumblrPicturePullTask target = new TumblrPicturePullTask();
            target.Enable = true;
            Guid newId = Guid.NewGuid();
            target.TaskName = "TumblrPicturePullTask-7";

            target.ExtendData = new Dictionary<string, string>();
            target.ExtendData[DWHConstants.KEY_TUMBLR_SITE_NAME] = "sexislovely";
            target.ExtendData[DWHConstants.KEY_CONTENT_PAGE_URL_PATTERN] = @"http://\d+.media.tumblr.com/tumblr";//http://24.media.tumblr.com/tumblr_m158zdQV1w1rqr5kgo1_500.jpg

            target.ExtendData[DWHConstants.KEY_LOOP_PAGELIST_URL_PATTERN] = "http://sexislovely.tumblr.com/page/{0}";//http://realsexrealpeople.tumblr.com/page/2
            target.ExtendData[DWHConstants.KEY_LOOP_PAGELIST_NUMBER_START] = "1";
            target.ExtendData[DWHConstants.KEY_LOOP_PAGELIST_NUMBER_END] = "10";
            target.ExtendData[DWHConstants.KEY_WEB_ATTACHMENT_STORE_FOLDER] = "E:/WebPPAttachment/Tumblr";
            target.ExtendData[DWHConstants.KEY_PAGE_TARGET_ELEMENT] = "//img";
            target.ExtendData[DWHConstants.KEY_PAGE_TARGET_ATTRIBUTE] = "src";

            target.ExtendData[DWHConstants.KEY_PAGE_ENCODING] = "gb2312";//gb2312
            target.ExtendData[DWHConstants.KEY_CONTENT_TARGET_ELEMENT] = "//div[@class]";
            target.ExtendData[DWHConstants.KEY_CONTENT_TARGET_ELEMENT_ATTRIBUTE_NAME] = "class";
            target.ExtendData[DWHConstants.KEY_CONTENT_TARGET_ELEMENT_ATTRIBUTE_VALUE] = @"postContent";

            target.Initialize();
            target.Run();
        }
    }
}
